﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using VideoClassLibrary.BusinessLogicLayer;
public partial class CourseManagement_TrainClassList : AdminUserBase
{
    public string currentSchoolName = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        TeacherModule ta = new TeacherModule();
        currentSchoolName = ta.GetSchNameByID(this.SchoolID);
        if (!IsPostBack)
        {
            BindPageData();
           
        }
    }
    public void BindPageData()
    {
        TrainClassModule tm = new TrainClassModule();
        DataSet ds = new DataSet();
        ds = tm.GetTrainclassListByWhere(this.SchoolID, " and  a.IsPublish=1");
        Repeater1.DataSource = getPage(ds);
        Repeater1.DataBind();
    }
    //public string GetSchNameByID(int schid)
    //{
    //    TeacherModule ta = new TeacherModule();
    //    string name = ta.GetSchNameByID(schid);
    //    return name;
    //}
    public PagedDataSource getPage(DataSet ds)
    {
        this.pager.RecordCount = ds.Tables[0].Rows.Count;
        PagedDataSource pds = new PagedDataSource();
        pds.DataSource = ds.Tables[0].DefaultView;
        pds.AllowPaging = true;
        pds.CurrentPageIndex = pager.CurrentPageIndex - 1;
        pds.PageSize = pager.PageSize;
        return pds;
    }
    protected void pager_PageChanged(object sender, EventArgs e)
    {
        BindPageData(); 
    }
    protected void btnfind_Click(object sender, EventArgs e)
    {
        TrainClassModule tm = new TrainClassModule();
        DataSet ds = new DataSet();
        string where = " and VTC_name like '%" + txtTCName.Text.Trim() + "%' and  a.IsPublish=1";
        ds = tm.GetTrainclassListByWhere(this.SchoolID,where);
        Repeater1.DataSource = getPage(ds);
        Repeater1.DataBind();

    }
}
